#include <iostream>
#include <vector>
//#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;


#define int long long

using namespace std;
const int N = 1e7 + 7;

int a[N], b[N];
int n, m, t, ans, k;

void solve() {
	scanf("%lld %lld", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &t);
		if (t == 0) a[0] = b[0] = 1;
		else t < 0 ? b[t * -1] += 1 : a[t] += 1;
	}
	for (int i = 1; i <= m; i++)    a[i] = a[i - 1] + a[i], b[i] = b[i - 1] + b[i];
	for (int j = 0; j <= m; j++)    
		ans = max(ans, 
			max(a[j] + b[(m - 2 * j) >= 0 ? (m - 2 * j) : 0],
				b[j] + a[(m - 2 * j) >= 0 ? (m - 2 * j) : 0]));
	cout << ans;
	return;
}

signed main() {
	solve();
	return 0;
}



//矿洞 (错误写法，麻了)
/*
ll ans;
map<int, int> mp;

const int N =1e5+1;
int n,m;
int a[N];
ll temp =0;
int  dfs(int pre, int step){

	if(step > m){
		return temp;
	}
	if(mp[pre] == 1){  //未访问
		mp[pre] = 2;   //区分一下,2是访问
		temp = temp+1;
	}

	dfs(pre+1, step+1);
	if(mp[pre+1]  != 0)
		mp[pre+1] = 1;


	dfs(pre-1, step+1);
	if(mp[pre-1]  != 0)
		mp[pre-1] = 1;
	ans =max(ans, temp);
	temp =0;
	return ans;
}


void solve(){

	dfs(0, 0);
	cout<<ans;
	return;
}





int main()
{
  cin>>n>>m;

  for(int i =1; i<=n ;++i){
	scanf("%d",&a[i]);
	mp[a[i]] = 1;
  }
  solve();


  return 0;
}

*/


//异或暴力
/*
const int N =1e5+1;
int n;
int a[N],f[N];
void  solve(){
	int temp =0;
	for(int i =1;i<=n;++i){
		for(int j =1;j<=n;++j){
			temp = max(temp, i^j);
		}
	}
	cout<<temp;
	return;
}


int main()
{
  cin>>n;
  for(int i =1;i<=n;++i){
	cin>>a[i];
  }
	for(int i =1;i<=n;++i){
	cin>>f[i];
  }
   solve();
  return 0;
}
*/


//封闭图形个数 
/*
const int N = 2e5+10;
int a[N];
int cunchu[10] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1};
int n;

int check(int x){
	int res = 0;
	while(x>0){
		int temp = x % 10;
		res += cunchu[temp];
		x /= 10;
	}
	return res;
}



//封闭图形
bool cmp(int a, int b){
	if(check(a) > check(b))
		return false;
	if(check(a) == check(b))
		return a < b;

	return true;
}



void solve(){

	sort(a+1, a+n+1, cmp);
	for(int i = 1; i <= n; ++i){
		cout<<a[i]<<" ";
	}
	return ;
}


int main()
{
	cin>>n;
	for(int i = 1; i <= n; ++i){
		cin>>a[i];
	}
	solve();


  return 0;
}









//有奖问答
/*
int ans = 0;

void dfs(int k, int sum)
{
  if(sum == 100 || k >= 31) //100分的时候停止答题
	return ;

  if(sum == 70) //只要70分就记录答案，这个很关键嗷，要不会少情况
	ans++;

  dfs(k + 1, sum + 10);
  dfs(k + 1, 0); //答错归0
}

//总共30到题目，答对10分，打错归0分
int main()
{
  dfs(0, 0);

  cout << ans << endl;
  return 0;
}
*/


//幸运数 
/*
int n = 100000000;
int ans;
bool check(int x){
	string temp = to_string(x);
	int size = temp.size();
	if(( size % 2 ) != 0)
		return false;

	ll temp1 =0;
	ll temp2 =0;
	for(int i =0; i< size/2; ++i){
		temp1 = temp1 + (temp[i] - '0');
	}
	for(int i =size/2; i< size; ++i){
		temp2 = temp2 + (temp[i] - '0');
	}
	if(temp1 == temp2)
		return true;

	return false;

}


void solve(){
	for(int i = 11; i < n; ++i){
		if( (i>= 100 && i <=999) || (i>= 10000 && i <=99999) || (i>= 1000000 && i <=9999999))
			continue;
		if(check(i))
			ans++;
	}
	cout<<ans;

	return ;
}


int main()
{
  solve();
  return 0;
}

*/




//召唤数学精灵
/*
ll N = 1e16;
ll a[200],b[200];
ll c[200];
ll n = 100202;

ll res =0;

int main(){
	ll _add=0;
	ll _cheng =1;
	//cin>>n;
	for(ll i = 1; i<=n; ++i){

		_add= (_add+i) %100;
		if(_add == 0)
			res++;


		//cout<<"a[i]:"<<a[i]<<'\n';
	}

	cout<< 2024041331404 * 20 +4+2;
	//cout<< res;
	return 0;
}
*/



//劲舞团
/*
long long ans;

bool check(char* a, char* b){
	int a1 = atoi(a);
	int b1 = atoi(b);
	if(abs(b1 - a1) > 1000)
		return false;
	else
		return true;
}
 char temp1[6] = "95591";
int main(){
	long long temp = 1;
	 FILE* fp = fopen("C:\\Users\\12525\\OneDrive\\桌面\\log.txt", "r");
	 if(!fp) {
		perror("File opening failed");
		return EXIT_FAILURE;
	}
	char line[256];


	char last5[6];
	while (fgets(line, sizeof(line), fp)) { // 逐行读取
	   if(line[0] == 'h' && line[2] == 'h' && line[10] == '6' &&line[11] == '1' &&line[12] == '3' &&line[13] == '9' &&line[14] == '5'
		&& line[15] == '9' &&line[16] == '1' )
			continue;
		printf("第一列:%c ", line[0]); // 处理每一行
		printf("第二列:%c ", line[2]); // 处理每一行
			//  	12-16

		strncpy(last5, line+12, 5) ;


		printf("第三列:%s\n", last5); // 处理每一行
		if(line[0] == line[2] && check(temp1, last5)) {
			temp = temp+1;
		}
		else
			temp = 1;

		ans = max(temp, ans);
		strncpy(temp1, last5, 6) ;
	}

	cout<<ans;

	return 0;
}

*/


//团建
/*
int n,m;
int res;
int a[N],b[N];
vector<int> G1[N];
vector<int> G2[N];

void dfs(int pre1, int fath1, int pre2, int fath2, int deep){
	res = max(res,deep);
	map<int,int> mp;
	for(auto v1 : G1[pre1]){
		if(v1 == fath1)
			continue;
		mp[a[v1]] = v1;
	}
	for(auto v2 : G2[pre2]){
		if(v2 == fath2)
			continue;
		if(mp[a[v2]]){
			dfs(mp[a[v2]], pre1, v2, pre2, deep+1);
		}
	}

	return;
}



int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n; ++i)
		scanf("%d",&a[i]);
	for(int i = 1; i <= m; ++i)
		scanf("%d",&b[i]);

	for(int i = 2; i <= n; ++i) {
		int u,v;
		scanf("%d%d",&u,&v);
		G1[u].push_back(v);
		G1[v].push_back(u);
	}
	for(int i = 2; i <= m; ++i) {
		int u,v;
		scanf("%d%d",&u,&v);
		G2[u].push_back(v);
		G2[v].push_back(u);
	}
	if(a[1] != b[1])
		printf("0\n");
	dfs(1,0,1,0,1);
	  cout<<res<<'\n';

  return 0;
}
*/